<template>
  <div id="usergashaponlist"> 


          <el-table :data="datalist" style="width: 100%" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
           :row-class-name="tableRowClassName"  :border="true">

 
                <el-table-column label="帐号"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.telphone }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="用户名"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.nickname }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="团队情况"  align='center' width="500px">                   
                    <template slot-scope="scope">
                        <span v-show="false">aa:{{ aaa }} </span> 
                        <span v-if="scope.row.see == 0"  @click="see_but(scope.row,scope.$index)"><i class="el-icon-view el-icon--right"></i></span>   
                         <div v-if="scope.row.see == 1">                
                            <span v-if="scope.row.inviter">推荐人:{{ scope.row.inviter.telphone }}</span>
                            <span v-if="scope.row.operate_center">所属运营中心:{{ scope.row.operate_center.name }}</span>
                            团队数:{{ scope.row.sub_invite_count }}
                            好友数:{{ scope.row.direct_invite_count }} 
                            <span @click="mtk_table_but(scope.row)"><i class="el-icon-view el-icon--right"></i></span>  
                         </div> 
                    </template>
                </el-table-column>
                <el-table-column label="扭蛋总数"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.cash_prize_all_num }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="扭蛋剩余"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.cash_prize_surplus_num }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="金蛋奖金池总数"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.cash_red_back_total_number }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="金蛋奖金池剩余"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.cash_red_back_number }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="金蛋已获得奖金"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.cash_red_back_used }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="彩蛋奖金池总数"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.range_cash_reward_total}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="彩蛋奖金池剩余"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.range_cash_reward }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="彩蛋已获得奖金"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.range_cash_reward_used }}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column label="系数比例"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.cash_reward_scale }}<i class="el-icon-edit" @click="edit_but(scope.row)"></i></span>
                    </template>
                </el-table-column> -->
    
            </el-table>  

       <el-dialog title="修改比例" :visible.sync="edit_mtk"  width="400px" :close-on-click-modal="false">
          <el-form ref="form" :model="edit_form"  label-width="100px" style="width:100%;">
                <el-form-item label="" label-width="0px">
                    <el-input v-model="edit_form.number" placeholder="请输入数量" ></el-input>
                </el-form-item>
                <div style="text-align: center;width:50%;margin:auto;margin-top:20px;">
                  <el-button type="primary" class="custom_color_button" style="width:100%;" @click="edit_but_qr">确认</el-button>
                </div>
         </el-form>
         </el-dialog> 


      <!-- 查看好友数 -->
        <el-dialog :title='mtk_table_title' :visible.sync="mtk_table"  width="700px">
            <div style="width:100%;"> 

             <el-table :data="mtk_table_form.datalist" style="width: 100%" height="500px" :header-cell-style="{background:'#4F81BC',color:'white'}"
           :row-class-name="tableRowClassName"  :border="true">
                
                 <el-table-column label="用户名"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.nickname }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="手机号"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.telphone }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="团队数"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.sub_invite_count }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="好友数"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.direct_invite_count }}</span><span @click="table_but(scope.row)"><i class="el-icon-view el-icon--right"></i></span> 
                    </template>
                </el-table-column>
            </el-table> 

               <div style="margin-top:20px;text-align: center;">
                    <el-pagination
                        background
                        @current-change="handleCurrentChange1"
                        :page-size="10"  
                        layout="prev, pager, next, jumper"
                        :total="count">
                    </el-pagination>
              </div> 


            </div> 
        </el-dialog>

   </div>
</template>

<script>

export default {
   name: 'usergashaponlist',
   props:{
      datalist:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
        page:1,
        count:0,
        my_uid:'',
        my_table_uid:'',
        mtk_table_title:'',
        mtk_table:false,
        mtk_table_form:{
            datalist:[{"name":"1111"}]
        },
        edit_mtk:false,
        edit_form:{
            number:''
        },
        aaa:'',
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 253
      
  },
  mounted (){
    
  },
  methods: {
     edit_but(row){
         this.my_uid = row.uid
         this.edit_mtk = true
         this.edit_form.number = row.cash_reward_scale
    },
    edit_but_qr(){
          this.post("/lottery_member/updateRewardScale", {
                    uid:this.my_uid,
                    cash_reward_scale:this.edit_form.number
                }).then(res => {
                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.$emit('up_list_fun')
                    this.edit_mtk = false
                    }else {
                    this.open1(res.message,'warning')
                }

             })
    },
    see_but(row,index){
        this.post("/lottery_member/teamInfo", {
                    uid:row.uid,
                }).then(res => {
                   console.log(res)
                   if(res.error_code == 0){
                        this.datalist[index].direct_invite_count = res.result.direct_invite_count
                        this.datalist[index].sub_invite_count = res.result.sub_invite_count
                        this.datalist[index].inviter = res.result.inviter
                        this.datalist[index].operate_center = res.result.operate_center
                        this.datalist[index].see = 1
                        this.aaa = index  //动态更新
                        
                    }else {
                    this.open1(res.message,'warning')
                    }

                  

          })
        //console.log(row)
    },

     mtk_table_but(row){
         this.my_table_uid = row.uid
         this.mtk_table_title = '查看好友数-' +row.telphone 
         this.page = 1
         this.mtk_table = true
         this.mtk_table_fun()
     },
     mtk_table_fun(){
          this.mtk_table_form.datalist = []
           this.post("/lottery_member/friendLsitData", {
              page:this.page,
              uid:this.my_table_uid
	        }).then(res => {
            this.count = res.result.count
            this.mtk_table_form.datalist = res.result.list

            //console.log(this.mtk_table_form.datalist,"ttt")
         })
     },
     table_but(row){
         this.my_table_uid = row.uid
         this.mtk_table_title = '查看好友数-' +row.telphone 
         this.page = 1
         this.mtk_table_fun()
     },
     handleCurrentChange1(val) {
        this.page = val
        this.mtk_table_fun()
        console.log(`当前页: ${val}`);
      },

  }
}
</script>


<style scoped>

</style>